package libra;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

import com.alibaba.nacos.api.config.annotation.NacosValue;

@Component
@RefreshScope
public class LoadConfig {
	/**
	 * 在Nacos整合SpringCloud之后
	 * 我们无法再通过@NacosValue获取配置属性值
	 * 只能使用@Value来进行配置属性值的获取、注入
	 */
	@Value("${msg}")
	private String msg;
	@Value(value = "${refresh}")
	private String refresh;
	@Value("${version}")
	private Double version;
	
	@PostConstruct
	public void init() {
		System.out.println("LoadConfig被执行初始化...");
	}
	@PreDestroy
	public void destory() {
		System.out.println("LoadConfig被执行销毁...");
	}
	
	
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public String getRefresh() {
		return refresh;
	}
	public void setRefresh(String refresh) {
		this.refresh = refresh;
	}
	public Double getVersion() {
		return version;
	}
	public void setVersion(Double version) {
		this.version = version;
	}
}
